import {lazy} from "react"
const Login = lazy(()=>import("../pages/Login"))
const Home = lazy(()=>import("../pages/Index/Home"))
const List = lazy(()=>import("../pages/Index/List"))
const Result = lazy(()=>import("../pages/Index/Result"))
const Detail = lazy(()=>import("../pages/Index/Detail"))
const ResultSon = lazy(()=>import("../pages/Resultson"))
const Notfind = lazy(()=>import("../pages/Notfin"))
// 根据不同的人来展示不同的左侧菜单
// admin 管理员可能能看三个页面，普通人可能就能看一个页面两个页面
export const adminchildren = [  // 超级管理员可以看的二级路由
    {
        path:"/home/list",
        element:<List></List>,
        tit:"列表"
    },
    {
        path:"/home/result",
        element:<Result></Result>,
        tit:"结果",
        children:[
            {
                path:"/home/result/resultson",
                element:<ResultSon></ResultSon>,
                tit:"结果子页"
            }
        ]

    },
    {
        path:"/home/detail",
        element:<Detail></Detail>,
        tit:"详情"
    }
]
export const userchildren = [   // 普通用户可以看的二级路由
    {
        path:"/home/result",
        element:<Result></Result>,
        tit:"结果"
    },
    {
        path:"/home/detail",
        element:<Detail></Detail>,
        tit:"详情"
    }
]
const routerconfig = [
    {
        path:"/login",
        element:<Login></Login>
    },
    {
        path:"/home",
        element:<Home></Home>,
        // 如果是管理员，我们给她渲染管理员的路由，如果是普通用户，就给她渲染普通用户的路由
        children:window.localStorage.getItem("user")==="admin" ? adminchildren :userchildren
    },
    {
        path:"*",
        element:<Notfind></Notfind>
    }
]
export default routerconfig